package ods

import java.io.{BufferedReader, FileReader}
import java.util.Properties
import java.util.concurrent.Future

import org.apache.kafka.clients.producer.{KafkaProducer, ProducerRecord, RecordMetadata}
import org.apache.kafka.common.serialization.StringSerializer

object ReadEventLogToKafka {
  def main(args: Array[String]): Unit = {
    val props: Properties = new Properties()
    props.put("bootstrap.servers", "linux100:9092")
    props.put("key.serializer", classOf[StringSerializer])
    props.put("value.serializer", classOf[StringSerializer])

    val producer = new KafkaProducer[String, String](props)
    val bufferedReader = new BufferedReader(new FileReader("E:/big_data/课程资料/阶段九/大数据正式班第九阶段/资料（软件包、代码、数据文件）/数据文件/实时数仓测试数据/eventlog.log"))
    var line: String = bufferedReader.readLine()
    while (line != null) {
      val record = new ProducerRecord[String, String]("stage9_event_log", line)
      producer.send(record)
      line = bufferedReader.readLine()
    }

  }
}
